package com.iodemo;

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author edy
 */
public class IOprivate {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入几个简体字");
        String str = scanner.nextLine();
        InputStream is = null;
        InputStreamReader isr = null;
        BufferedReader br = null;
        Map<String,String> map = new HashMap<>();


        try {
            is = new FileInputStream("/Users/edy/Desktop/file/jf_map_utf8.txt");
            isr = new InputStreamReader(is);
            br = new BufferedReader(isr);
            StringBuffer sbf = new StringBuffer();
            String len;
            while ((len = br.readLine()) != null) {
                String[] split = len.split(":");
                map.put(split[0],split[1]);
            }
            for (int i = 0; i < str.length(); i++) {
                char c = str.charAt(i);
                String fanti = map.get(String.valueOf(c));
                if (fanti == null) {
                    sbf.append(c);
                } else {
                    sbf.append(fanti);
                }
            }
            System.out.println(sbf.toString());





        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            IOUntilsDemo.close(br);
            IOUntilsDemo.close(isr);
            IOUntilsDemo.close(is);
        }

    }
}
